<?php 
	$keyword_search = array(
		"name" => "to_search",
		"id" => "to_search",
		"value" => "",
		"size" => 14,
		"maxlength" => 30,
		"class" => "post-search-keywords",
	);
	$submit = array(
		"name" => "submit",
		"id" => "submit",
		"value" => "Ok",
		"class" => "post-search-button",
	);
	$nopost_keyword_search = array(
			"name" => "to_search",
			"id" => "to_search",
			"value" => "",
			"maxlength" => 30,
			"class" => "post-search-keywords",
	);
	$submit_nopost = array(
			"name" => "submit",
			"id" => "submit",
			"value" => lang('label_search_submit'),
			"class" => "nopost-submit-button",
	);
?>
<div class="top shadow sized"></div>

<div class="content">
	<div class="blog-search shadow">
		<div class="label"><?=lang('label_blog_searchbox_label')?></div>
		<?=form_open('/blog/search')?>
			<?=form_input($keyword_search)?>
			<?=form_submit($submit)?>
		<?=form_close()?>
	</div>	

	<div class="post-container">
		<?php if(!count($posts->all)) : ?>
			<div class="post-wrap first">
				<div class="post-content">
					<div class="post post-shadow ">
						<div class="header">
							<div class="title">
								<span class="title-1 orange"><?=lang('label_blog_noposts_title')?></span><br/>
								<span class="title-2 orange"><?=lang('label_blog_noposts_subtitle')?></span>
							</div>
						</div>
					
						<div class="text">
							<p><?=lang('label_blog_noposts_text_1')?></p>
							<p style="font-size: 1.4em; text-align:center"><a href="/blog"><?=site_url()?>blog</a></p>
							<p><?=lang('label_blog_noposts_text_2')?></p>
							
							<div class="no-post-search">
								<h1><?=lang('label_blog_noposts_label_search')?></h1>
								<?=form_open('/blog/search')?>
									<?=form_input($nopost_keyword_search)?>
									<?=form_submit($submit_nopost)?>
								<?=form_close()?>
							</div>
							
							<div class="no-post-categories">
								<h1><?=lang('label_blog_noposts_label_explore')?></h1>
								<ul>
									<?php foreach ($categories as $c) :?>
										<li><a href="/blog/category/<?=$c->id?>" title="<?=$c->$uilang?>"><?=$c->$uilang?></a></li>
									<?php endforeach;?>
								</ul>
							</div>
							
							<div class="no-post-sections">
								<h1><?=lang('label_blog_noposts_label_knowmore')?></h1>
								<p><?=lang('label_blog_noposts_text_3')?> <a href="/auth/register"><?=lang('label_blog_noposts_text_4')?></a> <?=lang('label_blog_noposts_text_5')?></p>
								<ul>
									<li><a href="/home"><?=ucfirst(lang('label_menu_home'))?></a></li>
									<li><a href="/explore"><?=ucfirst(lang('label_menu_explore'))?></a></li>
									<li><a href="/ngos"><?=ucfirst(lang('label_menu_ngos'))?></a></li>
									<li><a href="/about"><?=ucfirst(lang('label_menu_about'))?></a></li>
								</ul>
							</div>
							<div class="social">
								<div class="icon"><a href=""><img src="/images/template/icon/social/facebook.png" title="<?=lang('label_blog_post_social_facebook')?>" alt="<?=lang('label_blog_post_social_facebook')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/twitter.png" title="<?=lang('label_blog_post_social_twitter')?>" alt="<?=lang('label_blog_post_social_twitter')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/google.png" title="<?=lang('label_blog_post_social_google')?>" alt="<?=lang('label_blog_post_social_google')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/delicious.png" title="<?=lang('label_blog_post_social_delicious')?>" alt="<?=lang('label_blog_post_social_delicious')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/rss.png" title="<?=lang('label_blog_post_social_rss')?>" alt="<?=lang('label_blog_post_social_rss')?>" /></a></div>
									<div class="clearfix"></div>
							</div>
						</div>
						
					</div>
					<div class="post-bottom-wrapper"><div class="post-bottom-bg"></div></div>
					<div class="post-left-wrapper"><div class="post-left-bg"></div></div>
				</div>
				
				<div class="post-meta shadow">
						<div class="dark categories">
							<h1><?=strtoupper(lang('label_blog_categories'))?></h1>
							<ul>
								<?php foreach ($categories as $c) :?>
									<li><a href="/blog/category/<?=$c->id?>" title="<?=$c->$uilang?>" class="orange"><?=$c->$uilang?> <span class="reduced">(<?=$c->posts_in_category?>)</span></a></li>
								<?php endforeach;?>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
			</div>
		<?php else : ?>
			<?php foreach($posts as $i=>$p) : ?>
				<div class="post-wrap<?=(!$i) ? " first" : ""?>">
					<div class="post-content">
						<div class="post post-shadow ">
							<div class="header">
								<div class="title">
									<a href="/blog/post/<?=$p->id?>" title="<?=$p->title?>" class="orange">
										<span class="title-1"><?=$p->title."(".$p->lang.")"?></span><br/>
										<span class="title-2"><?=$p->subtitle?></span>
									</a>
								</div>
							
								<div class="subtitle">
									<div><?=lang('label_blog_post_author')?>&nbsp;<a href="/profile/<?=$p->author->username?>" title="" class="orange-d"><?=$p->author->username?></a>&nbsp;<?=lang('label_blog_post_creation_date')?>&nbsp;<?=date(lang('misc_date_format'), strtotime($p->created))?></div>
									<div><?=lang('label_blog_post_category')?>:&nbsp;<a href="/blog/category/<?=$p->category->id?>" class="orange-d" title="<?=lang('label_blog_post_category')?>: <?=$p->category->en_us?>"><?=$p->category->$uilang?></a></div>
								</div>
							</div>
						
							<div class="text">
								
								<?php if($this->uri->segment(2) == "post") : ?>
									<?=$p->text?>
								<?php else: ?>
									<?=$p->text?>
									... <a href="/blog/post/<?=$p->id?>" class="orange" title="<?=lang('label_blog_post_read_more')?>"><?=lang('label_blog_post_read_more')?></a>.	
								<?php endif; ?>
								
								<div class="social">
									<div class="icon"><a href=""><img src="/images/template/icon/social/facebook.png" title="<?=lang('label_blog_post_social_facebook')?>" alt="<?=lang('label_blog_post_social_facebook')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/twitter.png" title="<?=lang('label_blog_post_social_twitter')?>" alt="<?=lang('label_blog_post_social_twitter')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/google.png" title="<?=lang('label_blog_post_social_google')?>" alt="<?=lang('label_blog_post_social_google')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/delicious.png" title="<?=lang('label_blog_post_social_delicious')?>" alt="<?=lang('label_blog_post_social_delicious')?>" /></a></div>
									<div class="icon"><a href=""><img src="/images/template/icon/social/rss.png" title="<?=lang('label_blog_post_social_rss')?>" alt="<?=lang('label_blog_post_social_rss')?>" /></a></div>
									<div class="clearfix"></div>
								</div>
								
								<div class="permalink">
									<?=lang('label_blog_post_permalink')?>: <a href="/blog/post/<?=$p->id?>" title="<?=$p->title?>" class="orange"><?=site_url()?>blog/post/<?=$p->id?></a>
								</div>
							</div>
							
						</div>
						<div class="post-bottom-wrapper">
							<div class="post-bottom-bg"></div>
						</div>
						<div class="post-left-wrapper">
							<div class="post-left-bg"></div>
						</div>
					</div>
					
					<div class="post-meta shadow">
						<div class="info">
							<div class="dark date">
								<div class="day orange"><?=date('d', strtotime($p->created))?></div>
								<div class="month-year orange-d"><strong><?=date('M', strtotime($p->created))?></strong> <?=date('Y', strtotime($p->created))?></div>
							</div>
							<div class="dark other">other</div>
							<div class="dark clearfix"></div>
						</div>
						<div class="dark related">
							<h1><?=strtoupper(lang('label_blog_related_posts'))?></h1>
							<ul>
								<?php foreach ($p->related_posts as $r) :?>
									<?php if ($p->title != $r->title) :?>
									<li><a href="/blog/post/<?=$r->id?>" title="<?=$r->title?>" class="orange"><?=$r->title?></a></li>
									<?php endif;?>
								<?php endforeach;?>
							</ul>
						</div>
						<div class="dark categories">
							<h1><?=strtoupper(lang('label_blog_categories'))?></h1>
							<ul>
								<?php foreach ($categories as $c) :?>
									<li><a href="/blog/category/<?=$c->id?>" title="<?=$c->$uilang?>" class="orange"><?=$c->$uilang?> <span class="reduced">(<?=$c->posts_in_category?>)</span></a></li>
								<?php endforeach;?>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
				
			<?php endforeach ;?>
			
			<? $pagination = ($this->uri->segment(2) != "post") ? $this->pagination->create_links() : ""; ?>
			<?=$pagination?>
		
		<?php endif; ?>
	</div>
</div>
<script>
$(function() {
	$( "input.nopost-submit-button" ).button({icons: {primary: "ui-icon-locked"}, text: true});
	$( "input.post-search-button" ).button({icons: {primary: "ui-icon-locked"}, text: false});
});
</script>